package com.bestcem.xm.user.handler;

import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.handler.context.CellWriteHandlerContext;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;


/**
 * 组织层级模板-填写须知sheet处理器
 *
 * @author wangyunyun <yunyun.wang@idiaoyan.com>
 * @version v1.0
 * @date 2022/7/19 15:27
 */
public class GroupIntroduceSheetHandler implements CellWriteHandler {

    @Override
    public void afterCellDispose(CellWriteHandlerContext context) {
        Cell cell = context.getCell();
        if (cell.getColumnIndex() == 0) {
            CellStyle cellStyle = cell.getCellStyle();
            // 设置第一列宽度
            context.getWriteSheetHolder().getSheet().setColumnWidth(cell.getColumnIndex(), 25600);
            if (cell.getRowIndex() == 0) {
                // 设置第一列第一行样式
                cellStyle.setWrapText(true);

                // 设置行高度
                cell.getRow().setHeight((short) 6000);

                cell.getRow().setRowStyle(cellStyle);
                cell.setCellStyle(cellStyle);
            }
        }
    }

}
